/*
定义外部的传感器数据，使用串口从其他单片机（arduino）接收传感器数据
*/
#pragma once

#include "transfer.h"

#if defined(_WIN32) || defined(__ICCARM__)
#pragma pack(1)
#endif

#define CONFIG_IR_CHANNEL_NUM        4       /**< sharp IR channel number. */

/* Edit by LAY start */
#define CONFIG_MOTOR_BIAS_DATA_TIMEOUT_MS         30      /**< 电机转向频率超时时间 in ms. */
/* Edit by LAY stop */

/*add by yujikang*/

typedef struct _MotorEncoder
{
  _u32 ticksDeltaL;
  _u32 ticksDeltaR;
} __attribute__((packed)) MotorEncoder;

typedef struct _Speed
{
  _s32 left_wheel;
  _s32 right_wheel;
} __attribute__((packed)) Speed;

typedef struct _IrBeacon
{
  long beacon;
} __attribute__((packed)) IrBeacon;

typedef struct _SensorDistance
{
	uint16_t size;
    uint16_t distance[CONFIG_IR_CHANNEL_NUM];
} __attribute__((packed)) SensorDistance;

typedef struct _RecvData
{
  MotorEncoder motorEncoder;
  IrBeacon _irBeacon;
  SensorDistance sensor_dis;
} __attribute__((packed)) RecvData;

void transfer_init(USART_TypeDef* _USARTx);
void get_external_data();
// void motor_send_speed();
void send_external_data(const _s32 lspeed, const _s32 rspeed);

/**临时放在这里*/
uint8_t ex_homeir_getmaindata(void);
/**临时放在这里*/
uint8_t ex_homeir_getleftdata(void);
/**临时放在这里*/
uint8_t ex_homeir_getrightdata(void);

uint32_t ex_sharpir_get(int ch);